﻿using GetSlaughterItem.API.Application.Commands.Week01.Manageres;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SlaughterItem.Common.Dtos;

namespace GetSlaughterItem.API.Controllers.SuYi
{
    /// <summary>
    /// 第一周任务企业显示
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Week1GetController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        IMediator mediator;
        /// <summary>
        /// 日志
        /// </summary>
        ILogger<Week01GetController> logger;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        /// <param name="logger">日志</param>
        public Week1GetController(IMediator mediator, ILogger<Week01GetController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }

        /// <summary>
        /// 企业分页显示查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> QueryBusub(BusinesQueryCommand cmd)
        {
            try
            {
                logger.LogInformation("企业分页显示查询");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("企业分页显示查询失败" + ex.Message);
                throw;
            }
        }
    }
}
